@ECHO OFF

echo Installing LightTPD ...
xcopy /S /Y /i "%~d0%~p0files\LightTPD" "%SYSTEMDRIVE%\www"
echo.

echo Copying instsrv.exe and srvany.exe to the LightTPD directory ...
copy /Y "%~d0%~p0files\instsrv.exe" "%SYSTEMDRIVE%\www\instsrv.exe"
copy /Y "%~d0%~p0files\srvany.exe" "%SYSTEMDRIVE%\www\srvany.exe"
echo.

echo Updating LightTPD configuration ...
copy /Y "%~d0%~p0files\lighttpd-inc.conf" "%SYSTEMDRIVE%\www\conf\lighttpd-inc.conf"
echo.

echo Creating LightTPD service ...
"%SYSTEMDRIVE%\www\instsrv.exe" LightTPD "%SYSTEMDRIVE%\www\srvany.exe"
regedit /S "%~d0%~p0files\service_lighttpd.reg"
echo.

echo Installing PHP ...
xcopy /S /Y /i "%~d0%~p0files\php-5.3.6-nts-Win32-VC9-x86" "%SYSTEMDRIVE%\www\php"
echo.

echo Creating PHP service ...
"%SYSTEMDRIVE%\www\instsrv.exe" PHP "%SYSTEMDRIVE%\www\srvany.exe"
regedit /S "%~d0%~p0files\service_php-cgi.reg"
echo.

echo Updating LightTPD and PHP services before running ...
reg add HKLM\SYSTEM\CurrentControlSet\services\LightTPD\Parameters /v AppDirectory /d %systemdrive%\www
reg add HKLM\SYSTEM\CurrentControlSet\services\PHP\Parameters /v AppDirectory /d %systemdrive%\www\php
echo.

echo Starting LightTPD, PHP, and CopSSH services ...
sc start PHP
sc start LightTPD
echo.

echo Setup of win-lighttpd-mysql-php is complete, press any key to exit.

pause > nul